package org.example.finalsecurities.controller;

import org.example.finalsecurities.entity.ChangeInfo;
import org.example.finalsecurities.service.ChangeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 戴诚棋
 * @version 1.0
 */
@RestController
@RequestMapping("/api/changeInfo")
public class ChangeInfoController {
    @Autowired
    private ChangeInfoService changeInfoService;
    //将爬取的数据插入数据库对应表中
    @GetMapping("/insert")
    public void insert(){
        changeInfoService.insertChangeInfo();
    }
    //查询数据库的t_price_change表,将数据使用json格式返回
    @GetMapping("/select")
    public List<ChangeInfo> getChangeInfoList(){
        return changeInfoService.getChangeInfoList();
    }
}

